package cn.zjh.controller;

import cn.zjh.dto.ProductDto;
import cn.zjh.service.IProductService;
import cn.zjh.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description:
 * @author: Bug修复机
 * @date: 2022年09月19日 ： 9:41
 * @version: ver1.0
 * @email tangli@itsource.cn
 */
@RestController
@RequestMapping("/product")
public class ProductController {

    @Autowired
    private IProductService productService;

    @PostMapping("/add")
    public JsonResult add(@RequestBody ProductDto productDto){
//        try {
//            productService.add(productDto);
//            return new JsonResult();
//        } catch (RuntimeException e) {
//            e.printStackTrace();
//            return new JsonResult(false, e.getMessage());
//        }catch (Exception e){
//            return new JsonResult(false, "操作失败，请重试！");
//        }
        return productService.add(productDto);
    }

}
